package main

import (
	"fmt"
	"time"
	"reflect"
)

func main() {
	t := time.Now()
	fmt.Println(t)
	fmt.Println(t.Format("2006-01-02 15:04:05"))

	t2 := t.Add(24 * time.Hour)
	fmt.Println(t2)

	d := t2.Sub(t)
	fmt.Println(d)//24h0m0s

	if t.Before(t2) {
		fmt.Println("t<t2")
	}
	if t2.After(t) {
		fmt.Println("t2>t")
	}
	if t.Equal(t) {
		fmt.Println("t=t")
	}
	//定时器
	fmt.Println(time.Now())
	c := time.After(10 * time.Second)//返回channel类型
	fmt.Println(reflect.TypeOf(c))
	t3 := <-c
	fmt.Println(t3)
	tm :=time.NewTimer(10 * time.Second)//返回Timer类型
	t3 = <-tm.C
	fmt.Println(t3)
}
